package org.apache.rocketmq.example.jlh.testconsumerstart;

import org.apache.rocketmq.client.producer.DefaultMQProducer;
import org.apache.rocketmq.client.producer.SendResult;
import org.apache.rocketmq.common.message.Message;

import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.List;

/**
 * @author JLHWASX   Email:2429890953@qq.com
 * @Description
 * @verdion
 * @date 2024/2/4 19:04
 */

public class DelayProduct {
        public static void main(String[] args) throws Exception {
            DefaultMQProducer producer = new DefaultMQProducer("producer_saint");
            producer.setNamesrvAddr("127.0.0.1:9876");
            producer.start();
            Message msg = new Message("consumer-timeout", "msg-body-001".getBytes(StandardCharsets.UTF_8));
            msg.setTags("msg-body-001");
            // 设置消息延时级别
            msg.setDelayTimeLevel(3);
            List<Message> list = new ArrayList<>();
            list.add(msg);
            SendResult send = producer.send(list);
            System.out.println("sendResult: " + send);
        }

}
